<?php

namespace App\Http\Middleware;

use Closure;

use Session;

class ALoginMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {   

        //通过session检测用户是否登录
        session_start();
        $uid=0;
        if(Session::has('id')){
            $uid = Session::get('id');
            return $next($request);
        }else{
            //跳转到登录页面
             // return $next($request);
            return redirect('/admin/login');
        }
    }
}
